﻿<!--头部文件-->
<include file="Public/header"/>
<!--头部文件结束-->


<div class="wrapper">
    <!--左侧菜单栏-->
    <include file="Public/menu"/>
    <!--左侧菜单栏结束-->

    <div class="main-panel">
        <nav class="navbar navbar-default">
            <div class="container-fluid">
				<div class="navbar-minimize">
					<button id="minimizeSidebar" class="btn btn-warning btn-fill btn-round btn-icon">
						<i class="fa fa-ellipsis-v visible-on-sidebar-regular"></i>
						<i class="fa fa-navicon visible-on-sidebar-mini"></i>
					</button>
				</div>
                <div class="navbar-header">
                    <a class="navbar-brand" href="#">员工资料编辑</a>
                </div>
            </div>
        </nav>



        <div class="content">
            <div class="container-fluid">

                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <form id="admin_form" class="form-horizontal" action="__APP__/Staffs/update/id/{$admin.id}" method="post">
                                <div class="content">
                                    <legend>员工资料编辑</legend>
                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label"></label>
                                            <div class="col-sm-6"></div>
                                        </div>
                                    </fieldset>

                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label"><span style="color:red">*&nbsp;</span>登陆账号</label>
                                            <div class="col-sm-6">
                                                <input class="form-control username" type="text" value="{$admin.username}" disabled="disabled" placeholder="登陆账号必须在5到20位字符长度之间" onkeyup="value=value.replace(/[^\S]+/g,'')"/>
                                            </div>
                                        </div>
                                    </fieldset>

                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label"><span style="color:red">*&nbsp;</span>真实姓名</label>
                                            <div class="col-sm-3" style="width:20%">
                                                <input class="form-control truename" value="{$admin.truename}" type="text" name="truename" placeholder="请输入员工真实姓名" onkeyup="value=value.replace(/[^\S]+/g,'')"/>
                                            </div>

                                            <label style="width:10%" class="col-sm-2 control-label"><span style="color:red">*&nbsp;</span>权限等级</label>
                                            <div class="col-sm-3" style="width:20%;">
                                                <select  class="form-control jurisdiction" name="jurisdiction">
                                                    <option value="no">请选择权限等级</option>
                                                    <option value="0">无权限</option>
                                                    <option value="1">普通权限</option>
                                                    <option value="2">高级权限</option>
                                                </select>
                                            </div>
                                        </div>
                                    </fieldset>


                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label"><span style="color:red">*&nbsp;</span>联系电话</label>
                                            <div class="col-sm-6">
                                                <input class="form-control phone" type="text" value="{$admin.phone}" name="phone" placeholder="请填入真实联系电话" onkeyup="value=value.replace(/[^1234567890]+/g,'')"/>
                                            </div>
                                        </div>
                                    </fieldset>

                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label"><span style="color:red">*&nbsp;</span>邮箱地址</label>
                                            <div class="col-sm-6">
                                                <input class="form-control email" value="{$admin.email}" type="text" name="email" placeholder="请输入邮箱地址" onkeyup="value=value.replace(/[^\S]+/g,'')"/>
                                            </div>
                                        </div>
                                    </fieldset>

                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label"><span style="color:red">*&nbsp;</span>居住地址</label>
                                            <div class="col-sm-6">
                                                <input class="form-control address" value="{$admin.address}" type="text" name="address" placeholder="请输入现居地交通地址" onkeyup="value=value.replace(/[^\S]+/g,'')"/>
                                            </div>
                                        </div>
                                    </fieldset>


                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">
                                                <input class="pwd"  type="checkbox" />
                                                <span id="sp" style="float:right;margin-top:2.5px;"> &nbsp;&nbsp;重置密码</span>
                                            </label>

                                            <div class="col-sm-6">
                                                <input class="form-control password" disabled="disabled" type="password" placeholder="请输入想要设置的新密码" onkeyup="value=value.replace(/[^\S]+/g,'')"/>
                                            </div>
                                        </div>
                                    </fieldset>

                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label"></label>
                                            <div class="col-sm-3">
                                                <span id="admin_success" style="padding-left:4%;color:red"></span>
                                            </div>
                                        </div>
                                    </fieldset>
                                </div>
                                <div class="footer text-left">
                                    <button id="button_yes" type="button" class="btn btn-info btn-fill">提交</button>
                                    <button id="button_no" type="button" onclick="window.location.href='__APP__/Staffs/index.html'" class="btn btn-info btn-fill">返回</button>
                                 <br/>
                                    <br/>
                                </div>
                            </form>
                        </div>
                    </div>
                    </div>
            </div>
        </div>

        <!--底部文件-->
        <include file="Public/footer"/>
        <!--底部文件结束-->


    </div>
</div>

</body>

    <!--   Core JS Files and PerfectScrollbar library inside jquery.ui   -->
    <script src="__ROOT__/public/js/jquery.min.js" type="text/javascript"></script>
    <script src="__ROOT__/public/js/jquery-ui.min.js" type="text/javascript"></script>
	<script src="__ROOT__/public/js/bootstrap.min.js" type="text/javascript"></script>


	<!--  Forms Validations Plugin -->
	<script src="__ROOT__/public/js/jquery.validate.min.js"></script>
	<!--  Plugin for Date Time Picker and Full Calendar Plugin-->
	<script src="__ROOT__/public/js/moment.min.js"></script>
    <!--  Date Time Picker Plugin is included in this js file -->
    <script src="__ROOT__/public/js/bootstrap-datetimepicker.js"></script>
    <!--  Select Picker Plugin -->
    <script src="__ROOT__/public/js/bootstrap-selectpicker.js"></script>
	<!--  Checkbox, Radio, Switch and Tags Input Plugins -->
	<script src="__ROOT__/public/js/bootstrap-checkbox-radio-switch-tags.js"></script>
	<!--  Charts Plugin -->
	<script src="__ROOT__/public/js/chartist.min.js"></script>
    <!--  Notifications Plugin    -->
    <script src="__ROOT__/public/js/bootstrap-notify.js"></script>
    <!-- Sweet Alert 2 plugin -->
	<script src="__ROOT__/public/js/sweetalert2.js"></script>
    <!-- Vector Map plugin -->
	<script src="__ROOT__/public/js/jquery-jvectormap.js"></script>
    <!--  Google Maps Plugin    -->
    <script src="__ROOT__/public/js/aa743e8f448a4792bad10d201a7080f6.js"></script>
	<!-- Wizard Plugin   -->
    <script src="__ROOT__/public/js/jquery.bootstrap.wizard.min.js"></script>
	<!--  Bootstrap Table Plugin    -->
	<script src="__ROOT__/public/js/bootstrap-table.js"></script>
	<!--  Plugin for DataTables.net  -->
	<script src="__ROOT__/public/js/jquery.datatables.js"></script>
    <!--  Full Calendar Plugin    -->
    <script src="__ROOT__/public/js/fullcalendar.min.js"></script>
    <!-- Light Bootstrap Dashboard Core javascript and methods -->
	<script src="__ROOT__/public/js/light-bootstrap-dashboard.js"></script>
	<!--   Sharrre Library    -->
    <script src="__ROOT__/public/js/jquery.sharrre.js"></script>
	<!-- Light Bootstrap Dashboard DEMO methods, don't include it in your project! -->
	<script src="__ROOT__/public/js/demo.js"></script>
<script src="__ROOT__/public/js/new_js.js"></script>

<script>
    $('li.Staffs').addClass('active');

    $('#button_yes').click(function(){
        $('#admin_success').text('');
        var truename=$('.truename').val();
        var jurisdiction=$('.jurisdiction').val();
        var phone=$('.phone').val();
        var email=$('.email').val();
        var address=$('.address').val();
        var password=$('.password').val();

        if(truename == ''){
            $('#admin_success').text('请输入员工真实姓名');
        }else if(jurisdiction == 'no'){
            $('#admin_success').text('请选择权限等级');
        }else if(phone.length != 11){
            $('#admin_success').text('请输入11位有效联系电话');
        }else if(email == ''){
            $('#admin_success').text('请输入邮箱地址');
        }else if(address == ''){
            $('#admin_success').text('请输入详细居住地址');
        }else if($('.password').attr('name')=='password' && (password.length < 5 || password.length > 30)){
            $('#admin_success').text('密码必须在5到30位字符长度之间');
        }else{
            verify();
        }
    })


    function verify(){
        var phone=$('.phone').val();
        var email=$('.email').val();
        $.ajax({
            type:'post',
            url:"__APP__/Staffs/edit_sole",
            data:'phone='+phone+'&email='+email+'&id={$admin.id}',
            success:function(data){
                if(data=='exist-phone'){
                    $('#admin_success').text('已存在的联系电话');
                }else if(data=='exist-email'){
                    $('#admin_success').text('已存在的邮箱地址');
                }else if(data=='ok'){
                    $('#admin_form').submit();
                }
            }
        })

    }
</script>
<script>
    $('.jurisdiction option[value={$admin.jurisdiction}]').prop('selected','selected');

    $('.pwd').click(function(){
        if($('.pwd').prop('checked')==true){
            $('.password').prop('disabled','').attr('name','password');
        }else{
            $('.password').val('').prop('disabled','disabled').removeAttr('name');
        }
    })
</script>
</html>
